package com.lianda.mutiple.pattern.aobj.general;

import com.lianda.mutiple.pattern.aobj.example.OrderService;
import com.lianda.mutiple.pattern.future.Future;
import com.lianda.mutiple.pattern.future.FutureService;

import java.util.concurrent.TimeUnit;

public class NewOrderServiceImpl implements OrderService {


    @Override
    public Future<String> findOrderDetails(long orderId) {
        return FutureService.<Long, String>newService().submit(input -> {
            try {
                TimeUnit.SECONDS.sleep(10);
                System.out.println("New, process the orderID->" + orderId);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            return "The order Details Information";
        }, orderId, null);
    }

    @Override
    public void order(String account, long orderId) {
        System.out.println("New, account=" + account + ", orderId=" + orderId);
    }
}
